package demo2.assignment4;

import java.util.Scanner;

/**
 * @author Leon(赵亮)
 * @version 1.0.0
 * 10 Sep 2021
 * this is Tax calculate with Strategy Pattern, user can choose 1(US),2(CA),3(MX),4(JP) to use different Strategy to
 * Implement the Tax Calculate, and Leon run run run.
 */
public class TestTaxCalculate {

    public static void main(String[] args) throws InterruptedException {
        TaxCalculate taxCalculate;
        Scanner scanner = new Scanner(System.in);
        System.out.println("please input the number to test it's countries tax(0 to exit):\n" +
                "1.US \t\t2.Mexico\t\t3.Canada\t\t4.Japan");
        while (true) {
            int nextInt = scanner.nextInt();
            switch (nextInt) {
                case 1:
                    taxCalculate = new USTaxCalculate();
                    break;
                case 2:
                    taxCalculate = new MexicoTaxCalculate();
                    break;
                case 3:
                    taxCalculate = new CanadaTaxCalculate();
                    break;
                case 4:
                    taxCalculate = new JapanTaxCalculate();
                    break;
                default:
                    System.exit(0);
                    return;
            }
            double calculateTax = taxCalculate.calculateTax(1000000);
            System.err.println("the result of " + taxCalculate.getClass().getSimpleName() + " is " + calculateTax);
            Thread.sleep(1000);
            System.out.println("input again:");
        }
    }
}
